/** @jsxImportSource @emotion/react */
import * as React from "react";
import { OriginalViewProps, } from "../../common/base";
import {config设备概况, EntranceSetup, } from "./orcBase";
import { createItem,  } from "../../common/eHelper";
import {useRecordListSubr} from "../../hook/useRecordListSub";
import {DeviceSurveyPrf, VsProjects默认} from "./editor";
import {Macroscopic,} from "./Macroscopic";
import {BlobInputList,} from "customize-easy-ui-component";
import {ProjectListRq} from "../../vessel/editProj";
import {ConclusionBoiWb} from "../external/editor";
import {Defecthandle} from "./editDefect";
import {BoilerDiagram} from "./editSimpic";
import {OverheatingSys, PressureComponents} from "./editPresCm";
import {MaterialReview} from "./MaterialReview";
import {DiagramManager, SingleLineDiagram} from "../editorLineDg";
import {DrawingsExplan} from "./DrawingsExplan";
import {tableSetInp} from "../../../common/tool";
import {DeflectionCalc, LargeSlabBeam} from "./LargeSlabBeam";
import {DimensionInsp} from "./DimensionInsp";
import {CutPipeScale} from "./CutPipeScale";

const dlistDrawing=['附页：（电站锅炉内部检验联络单或意见书反馈）','附页：（使用单位检验偏离单）','附页：（特种设备检验意见书回复情况）'];
const editAs=(inp:any, setInp:React.Dispatch<React.SetStateAction<any>>, dxtix:number,refWidth?:number)=>{
  return <div css={{width: '100%'}}>
      首先选择输入该份的标题名：
      <BlobInputList value={inp?.联络单?.[dxtix]?.til || ''} datalist={dlistDrawing}
                     css={{display: 'inline-flex',
                       minWidth: refWidth!>450? 'unset':'100%',  width:  refWidth!>450? '25rem':'unset',
                     }} rows={2}
                     onListChange={v => tableSetInp('联络单', dxtix, inp, setInp, 'til', v || undefined)}/>
    </div>;
};

const recordPrintList =[
  createItem('Entrance', <EntranceSetup/>),
  createItem('ProjectList', <ProjectListRq config={VsProjects默认}  label={'目录页'}/>),
  createItem('Survey', <DeviceSurveyPrf config={config设备概况} label={'锅炉内部检验结论报告-设备概况'}/>),
  createItem('Conclusion', <ConclusionBoiWb label={'锅炉内部检验结论报告-下结论'}/>),
  createItem("Defecthandle", <Defecthandle label={'缺陷和问题的处理或者整改情况'}/>),
  createItem('BoilerDiagram', <BoilerDiagram label="锅炉简图"/>),
  createItem('PressureComponents', <PressureComponents label='主要受压元件情况(上)'/>),
  createItem('OverheatingSys', <OverheatingSys label='主要受压元件情况(下)'/>),
  createItem('MaterialReview', <MaterialReview label={'资料查阅报告'}/>),
  createItem('Macroscopic', <Macroscopic label={'宏观检查报告'}/>),
    //简易版本得原始记录：是无法显示全部得该部件图编辑器得，只会显示默认第一条得。 常规分项报告模式的也是分离式的编辑器需跳转打印也须分别打后归并。
  createItem('LineDiagram', <SingleLineDiagram />),
  createItem('DiagramManager', <DiagramManager />),

  createItem('LargeSlabBeam', <LargeSlabBeam label='大板梁挠度检查报告'/>),
  createItem('DeflectionCalc', <DeflectionCalc label='大板梁挠度检查-测量表'/>),
  createItem('DimensionInsp', <DimensionInsp table={'尺寸表'} label='尺寸检查报告'/>),
  createItem('CutPipeScale', <CutPipeScale table={'割管表'} label='割管垢样检验报告'/>),

  createItem('DrawingsExplan', <DrawingsExplan table={'联络单'} editAs={editAs} label='联络单意见书回复检验偏离单'/>),
  createItem('_Controller',  <></>),
];

export const OriginalView=
  React.forwardRef((
    { action: modAction,  verId, repId='', rep}
    :OriginalViewProps, ref
  ) => {
    const {list}=useRecordListSubr(ref,rep,recordPrintList,modAction,verId);
    return <React.Fragment>
      {list}
    </React.Fragment>;
  } );
